/************************************************************************/
/* GUI                                                                  */
/************************************************************************/
#include "GUI/Bars/BaseBar.h"

namespace TD_GUI {


   /************************************************************************/
   /* Default definitions                                                  */
   /************************************************************************/
   const unsigned int BaseBar::backgroundOffset = 2; //2 pixels


   BaseBar::BaseBar() {

   }


   BaseBar::BaseBar(const BaseBar &rhs) {

   }

   BaseBar & BaseBar::operator =(const BaseBar & rhs) {
      return(*this);
   }

   BaseBar::BaseBar(const Coord2D & barPosition, const Coord2D & barSize,
      const Color &foregroundColor /* = Color::GREEN */, const Color &backgroundColor /* = Color::BLACK */) : BaseEntity(barPosition) {

         m_size = barSize;
         m_foregroundColor = foregroundColor;
         m_backgroundColor = backgroundColor;

         m_foregroundRect.w = 0;
   }

   BaseBar::~BaseBar() {

   }


   void BaseBar::update(const unsigned int deltaTime) {

   }

   void BaseBar::render(SDL_Surface *const g_destSurface, unsigned int deltaTime) {
      m_backgroundRect.x = m_position.x;
      m_backgroundRect.y = m_position.y;

      m_backgroundRect.w = m_size.x;
      m_backgroundRect.h = m_size.y;

      m_foregroundRect.x = m_position.x + backgroundOffset;
      m_foregroundRect.y = m_position.y + backgroundOffset;

      update(deltaTime);
      m_foregroundRect.h = m_size.y - backgroundOffset;


      SDL_FillRect(g_destSurface, &m_backgroundRect, SDL_MapRGB(g_destSurface->format, m_backgroundColor.red, m_backgroundColor.green, m_backgroundColor.blue));
      SDL_FillRect(g_destSurface, &m_foregroundRect, SDL_MapRGB(g_destSurface->format, m_foregroundColor.red, m_foregroundColor.green, m_foregroundColor.blue));

   }
}